<template>
  <view class="container">
    <TImage
      :src="currentUser.avatar"
      height="750rpx"
      width="100%"
      border-radius="40rpx 40rpx 0 0"
      mode="aspectFill"
      error-img-type="person"
    />
    <view class="info">
      <view class="user-basic">
        <view class="name-box">
          <view class="name">
            {{ currentUser.name || '暂无姓名' }}
          </view>
          <view v-if="currentUser.sex === SexEnum.MALE" class="male">
            <text class="ali-icon icon-nanxing"></text>
          </view>
          <view v-else-if="currentUser.sex === SexEnum.FEMALE" class="female">
            <text class="ali-icon icon-nvxing"></text>
          </view>
          <view v-if="isShow(currentUser.memberLevelName)" class="member-level-name">
            <text v-if="currentUser.applyMember" @click="handleToSelectiveType">成为会员 ></text>
            <text v-else>{{ currentUser.memberLevelName || '暂无会员职务' }}</text>
          </view>
          <view v-if="currentUser.self" class="tip">完善资料可提升曝光</view>
        </view>
        <view class="company-box">
          <view>
            {{ currentUser.companyPositionName || '暂无职务' }}
          </view>
          <view class="_gap">|</view>
          <view>
            {{ currentUser.companyName || '暂无单位' }}
          </view>
        </view>
        <view class="native-box">
          <view class="home">
            <text class="ant-iconfont icon-home1"></text>
            <view>
              {{ currentUser.nativePlaceStr || '暂无籍贯' }}
            </view>
          </view>
          <view class="school">
            <text class="ali-icon icon-xuexiao"></text>
            <view>{{ currentUser.schoolName || '暂无学校' }}</view>
          </view>
        </view>
      </view>
      <view class="resource">
        <view class="title">可提供资源</view>
        <view class="desc">{{ currentUser.resource || '暂未填写' }}</view>
      </view>
      <view class="demand">
        <view class="title">需求资源</view>
        <view class="desc">{{ currentUser.demand || '暂未填写' }}</view>
      </view>
    </view>
  </view>
</template>
<script setup lang="ts">
  import type { RegisterIdAppUserInfo } from '@/api/activity/types';
  import type { PropType } from 'vue';
  import TImage from '@/components/TImage/index.vue';
  import { SexEnum } from '@/enums/loginEnum';
  import { navigateTo } from '@/router';
  const props = defineProps({
    currentUser: {
      type: Object as PropType<RegisterIdAppUserInfo>,
      default: () => ({}),
    },
  });

  const isShow = (val: string) => {
    if (props.currentUser.self) return true;
    if (val) return true;
    return false;
  };

  const handleToSelectiveType = () => {
    navigateTo({
      name: 'selectiveType',
    });
  };
</script>
<style lang="scss" scoped>
  .container {
    .info {
      padding: 40rpx;
      position: relative;
      top: -40rpx;
      display: flex;
      flex-direction: column;
      gap: 8rpx;
      border-radius: 32rpx 32rpx 0px 0px;
      background: #fff;
      min-height: 600rpx;

      .user-basic {
        display: flex;
        flex-direction: column;
        gap: 16rpx;
        margin-bottom: 16rpx;
        .name-box {
          display: flex;
          gap: 16rpx;
          align-items: center;
          .name {
            color: #333;
            font-size: 36rpx;
            font-weight: bold;
            line-height: 56rpx;
          }
          .member-level-name {
            border-radius: 24rpx;
            background: linear-gradient(90deg, #fdedc7 0.12%, #f7d9a2 100%);
            color: #ea5e0e;
            font-size: 24rpx;
            line-height: 32rpx;
            padding: 8rpx 24rpx;
          }
          .tip {
            color: #ea5e0e;
            justify-self: self-end;
            font-size: 24rpx;
            line-height: 32rpx;
            flex: 1;
            text-align: right;
          }
          .male,
          .female {
            width: 48rpx;
            height: 48rpx;
            font-size: 32rpx;
            border-radius: 60rpx;
            display: flex;
            justify-content: center;
            align-items: center;
          }

          .male {
            color: #2878ff;
            background: rgba(40, 120, 255, 0.2);
          }
          .female {
            color: #ea5e0e;
            background-color: rgba(234, 94, 14, 0.2);
          }
        }

        .company-box {
          display: flex;
          align-items: center;
          color: #333;
          font-size: 24rpx;
          font-weight: bold;
          line-height: 32rpx;
          gap: 8rpx;
          ._gap {
            color: #c8cacc;
            font-size: 24rpx;
            font-weight: bold;
            line-height: 32rpx;
            width: 24rpx;
            text-align: center;
          }
        }
        .native-box {
          display: flex;
          gap: 32rpx;
          align-items: center;
          .home,
          .school {
            display: flex;
            align-items: center;
            gap: 8rpx;
            color: #969799;
            font-size: 24rpx;
            line-height: 32rpx;
            .ant-iconfont {
              font-size: 32rpx;
            }
            .ali-icon {
              font-size: 32rpx;
            }
          }
        }
      }

      .resource,
      .demand {
        padding: 24rpx 0;
        .title {
          color: #333;
          font-size: 32rpx;
          font-weight: bold;
          line-height: 48rpx;
        }
        .desc {
          margin-top: 24rpx;
          color: #646566;
          font-size: 24rpx;
          line-height: 36rpx;
        }
      }
    }
  }
</style>
